package com.action;

import java.io.File;
import java.util.Date;
import java.util.List;
import java.util.Map;

import org.apache.struts2.ServletActionContext;

import com.dao.AdvDAO;
import com.model.Adv;
import com.opensymphony.xwork2.ActionSupport;


public class systemAction extends ActionSupport {
	
	private AdvDAO advDAO;
	private Adv adv;
	private String fujian;
	private String fujianYuanshiming;
	private Long id;
	
	public Long getId() {
		return id;
	}


	public void setId(Long id) {
		this.id = id;
	}

	public String getFujian() {
		return fujian;
	}


	public void setFujian(String fujian) {
		this.fujian = fujian;
	}


	public String getFujianYuanshiming() {
		return fujianYuanshiming;
	}


	public void setFujianYuanshiming(String fujianYuanshiming) {
		this.fujianYuanshiming = fujianYuanshiming;
	}


	public Adv getAdv() {
		return adv;
	}


	public void setAdv(Adv adv) {
		this.adv = adv;
	}


	public AdvDAO getAdvDAO() {
		return advDAO;
	}


	public void setAdvDAO(AdvDAO advDAO) {
		this.advDAO = advDAO;
	}


	public String slide() {
		
		List<Adv> advList = advDAO.findAll();
		Map request=(Map)ServletActionContext.getContext().get("request");
		request.put("advList", advList);
		return ActionSupport.SUCCESS;
	}
	
	public String slideAdd() {
		System.out.print(adv);
		System.out.println(fujian);
		adv.setGmtCreate(new Date());
		adv.setGmtModified(new Date());
		adv.setAdvLocation(1);
		adv.setAdvTarget("_blank");
		adv.setAdvImg(fujian);
		adv.setPlatShow(0);
		advDAO.save(adv);
		return "succeed";
	}
	
	public String slideDel() {
		Adv adv = advDAO.findById(id);
		advDAO.delete(adv);
		return "succeed";
	}

}
